package com.blog.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.websocket.server.PathParam;

@Controller
@RequestMapping("/page")
public class PageController {

    /**文章详情**/
    @RequestMapping(value = "/editor/{articleId}")
    public String editor1(HttpServletRequest request,@PathVariable String articleId){
        request.setAttribute("articleId",articleId);
        return "user/editor";
    }
    /**文章编辑**/
    @RequestMapping(value = "/editor")
    public String editor2(HttpServletRequest request){
        request.setAttribute("articleId","");
        return "user/editor";
    }
    /**文章管理**/
    @RequestMapping("/list")
    public String list(){
        return "user/list";
    }
    /**用户管理**/
    @RequestMapping("/user")
    public String user(HttpSession session){
        Boolean isAdmin = (Boolean) session.getAttribute("isAdmin");
        if (isAdmin == null || isAdmin.equals(false)) {
            return "user/403";
        }
        return "user/user";
    }

    /**评论管理**/
    @RequestMapping("/discuss")
    public String discuss(){
        return "user/discuss";
    }
    /**首页**/
    @RequestMapping("/index")
    public String index(){
        return "user/index";
    }
    /**用户中心**/
    @RequestMapping("/info")
    public String info(){
        return "user/userinfo";
    }
    /**修改密码**/
    @RequestMapping("/pass")
    public String pass(){
        return "user/pass";
    }
}
